<div id="information">
<br /><br />
<?php
    if($_GET['moda']=="delete"){
	 $delete_gallery='DELETE FROM gallery WHERE id="'.$_GET['id'].'"';
	 $results_delete_articles=mysql_query($delete_gallery);
	 
	 echo '
	 <script type="text/javascript">
		alert("Успешно Изтриване!");
	 </script>
	 ';
	echo '<meta http-equiv="refresh" content="0;url=gallery.php?name='.$_GET['name'].'">';
	} else {
	$select_gal=mysql_query('SELECT * FROM gallery WHERE place = "'.$_GET['name'].'" ORDER BY date_added DESC');
	$select_u=mysql_query('SELECT type, username FROM users WHERE username="'.$_SESSION['username'].'"');
	$row_u=mysql_fetch_assoc($select_u);
	
	if(mysql_num_rows($select_gal)==0){
	   echo '<p class="error">Няма галерии към този самоучител</p>';
	}
	$select_user = mysql_query('SELECT type FROM users WHERE username = "'.$_SESSION['username'].'"');
    $row_user = mysql_fetch_assoc($select_user);
	while($row_g=mysql_fetch_assoc($select_gal)){
	$sel_gall=mysql_query('SELECT * FROM images WHERE `to`="'.$row_g['name'].'"');
	$last_pic=mysql_query('SELECT * FROM images WHERE `to`="'.$row_g['name'].'" LIMIT 1');
	$last_pic_ord=mysql_fetch_assoc($last_pic);
	?>
	<div style="float: right; margin-right: 15px;">Снимки: <b><?php echo mysql_num_rows($sel_gall); ?></b></div>
	<?php
	   if(mysql_num_rows($last_pic)!=0){
	   echo '<p style="float: left;"><img src="../site_pict/thumbs/'.$last_pic_ord['id'].'.jpg" class="style_pict"/></p>';
	   } else {
	   echo '<p style="float: left;"><img src="../site_pict/no.jpg" width="180px" height="120px"/></p>';
	   }
	   echo "<p style='position: relative; right: -15px; bottom: -25px;'><a href='view_gallery.php?name_g=".$row_g[name]."&amp;name=".$_GET[name]."' class='message'>".$row_g['name']."</a> / <a href='../Galerry/gallery.php?name2=$row_g[name]&amp;name=$_GET[name]' class='f'>Виж галерията в пълен размер</a></p>";
	   echo "<p style='position: relative; right: -15px; bottom: -25px;'>".$row_g['descr']."</p>";
	   echo "<p style='position: relative; right: -170px; bottom: -55px;'><b>Добавена: </b>".date('d-m-Y', $row_g[date_added])." от ".$row_g['from_who']."</p>";
	   echo "<br />";
	   echo "<br />";
	   echo "<br />";
	   echo "<br />";
	   echo "<hr width='85%'/>";
	}  
	}
	?>
</div>